# THIS FILE IS LICENSED UNDER THE MIT LICENSE AS OUTLINED IMMEDIATELY BELOW: 
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),  
# to deal in the Software without restriction, including without limitation  
# the rights to use, copy, modify, merge, publish, distribute, sublicense,  
# and/or sell copies of the Software, and to permit persons to whom the  
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in 
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
# DEALINGS IN THE SOFTWARE.

# eye.py
# written by: 
#     Jan Jokela <jan@devion.org>

__version__ = 0.3
__doc__ = 'the all seeing eye'

import pygame
from pygame.locals import *
import qgl
import qgle
import events

# compiles the scenegraph
compiler = qgl.render.Compiler()
# renders the scenegraph
render = qgl.render.Render()
# picks qgl.scene.Group's
picker = qgl.render.Picker()
# the scenegraph's root node
root_node = qgl.scene.Root()
# let's use a perspective viewport
viewport = qgl.scene.PerspectiveViewport()

eventhandler = events.EventHandler()
actionhandler = events.ActionHandler()
mousehandler = events.MouseHandler()

target_fps = 30
fps = 30

def config_viewport(screen_dimensions=(0,0,800,480), aspect=(800.0 / 500.0)):
    """
        - screen dimensions are the virtual displayed resolution
        inside the real displayed resolution
        - aspect is the aspect ratio of the virtusal resolution (dimension)
    """
    
    viewport.screen_dimensions = screen_dimensions
    viewport.aspect = aspect
    root_node.add(viewport)
    
def config_dimensions(w=800, h=480):
    screen_dimensions=(0,0,w,h)
    viewport.screen_dimensions = screen_dimensions
    flags = RESIZABLE|OPENGL|DOUBLEBUF|HWSURFACE
    pygame.display.set_mode((w,h), flags)
    
def config_screen(resolution=(800,480), flags=RESIZABLE|OPENGL|DOUBLEBUF|HWSURFACE, caption='fluid experiences'):
    """
    Uses pygame to initialize our window, fullscreen or in a window
    """
    pygame.init()
    pygame.display.set_mode(resolution, flags)
    pygame.display.set_caption('mediaplex')